
// Menampilkan pesan kesalahan dalam pemilih tertentu
function pesanError(selector, pesan) {
    var html = '';
    html += '<div class="ui-messages ui-widget">';
    html += '<div class="ui-messages-error ui-corner-all">';
    html += '<span class="ui-messages-error-icon"></span>';
    html += '<ul><li><span class="ui-messages-error-summary">ERROR </span><span class="ui-messages-error-detail">' + pesan + '</span></li></ul>';
    html += '</div>';
    html += '</div>';
    
    $(selector).html(html);
}

// Tampilan pesan peringatan di pemilih tertentu
function pesanWarning(selector, pesan) {
    var html = '';
    html += '<div class="ui-messages ui-widget">';
    html += '<div class="ui-messages-warn ui-corner-all">';
    html += '<span class="ui-messages-warn-icon"></span>';
    html += '<ul><li><span class="ui-messages-warn-summary">WARNING </span><span class="ui-messages-warn-detail">' + pesan + '</span></li></ul>';
    html += '</div>';
    html += '</div>';
    
    $(selector).html(html);
}

// Menampilkan info pesan dalam pemilih tertentu
function pesanInfo(selector, pesan) {
    var html = '';
    html += '<div class="ui-messages ui-widget">';
    html += '<div class="ui-messages-info ui-corner-all">';
    html += '<span class="ui-messages-info-icon"></span>';
    html += '<ul><li><span class="ui-messages-info-summary">INFO </span><span class="ui-messages-info-detail">' + pesan + '</span></li></ul>';
    html += '</div>';
    html += '</div>';
    
    $(selector).html(html);
}

// Pesan yang jelas dalam pemilih ditentukan
function bersihkanPesan(selector) {
    $(selector).html('');
}

// Format Tanggal objek menjadi string tanggal dengan pemisah tertentu
function formatFilterDate(aDate, separator) {
    var month   = aDate.getMonth() + 1;
    var day     = aDate.getDate();
    var year    = aDate.getFullYear();
	   
    if(month < 10) month = '0' + month;
    if(day < 10) day = '0' + day;
	   
    return day + separator + month + separator + year;
}

// Enable only numeric characters
// See ASCII number for reference
function numericOnlyNoSymbol() {
    
    var key = window.event ? event.keyCode : event.which;

    // Backspace allowed
    if (event.keyCode == 8) return true;

    else if ( key < 48 || key > 57 ) return false;
    
    else return true;
}


function hasNumbers(t) {
    return /\d/.test(t);
}